home *** CD-ROM | disk | FTP | other *** search
- # This file is a Tcl script to test out the "place" command. It is
- # organized in the standard fashion for Tcl tests.
- #
- # Copyright (c) 1995 Sun Microsystems, Inc.
- #
- # See the file "license.terms" for information on usage and redistribution
- # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- #
- # @(#) place.test 1.3 95/06/04 14:23:09
-
- if {[info procs test] != "test"} {
- source defs
- }
-
- foreach i [winfo children .] {
- destroy $i
- }
- wm geometry . {}
- raise .
-
- # XXX - This test file is woefully incomplete. At present, only a
- # few of the features are tested.
-
- toplevel .t -width 300 -height 200 -bd 0
- wm geom .t +0+0
- frame .t.f -width 154 -height 84 -bd 2 -relief raised
- place .t.f -x 48 -y 38
- frame .t.f2 -width 30 -height 60 -bd 2 -relief raised
- update
-
- test place-1.1 {Tk_PlaceCmd procedure, "info" option} {
- place .t.f2 -x 0
- place info .t.f2
- } {-x 0 -relx 0 -y 0 -rely 0 -width {} -relwidth {} -height {} -relheight {} -anchor nw}
- test place-1.2 {Tk_PlaceCmd procedure, "info" option} {
- place .t.f2 -x 1 -y 2 -width 3 -height 4 -relx 0.1 -rely 0.2 \
- -relwidth 0.3 -relheight 0.4 -anchor se -in .t.f \
- -bordermode outside
- place info .t.f2
- } {-x 1 -relx 0.1 -y 2 -rely 0.2 -width 3 -relwidth 0.3 -height 4 -relheight 0.4 -anchor se -bordermode outside -in .t.f}
-
- test place-2.1 {ConfigureSlave procedure, -height option} {
- list [catch {place .t.f2 -height abcd} msg] $msg
- } {1 {bad screen distance "abcd"}}
- test place-2.2 {ConfigureSlave procedure, -height option} {
- place forget .t.f2
- place .t.f2 -in .t.f -height 40
- update
- winfo height .t.f2
- } {40}
- test place-2.3 {ConfigureSlave procedure, -height option} {
- place forget .t.f2
- place .t.f2 -in .t.f -height 120
- update
- place .t.f2 -height {}
- update
- winfo height .t.f2
- } {60}
-
- test place-3.1 {ConfigureSlave procedure, -relheight option} {
- list [catch {place .t.f2 -relheight abcd} msg] $msg
- } {1 {expected floating-point number but got "abcd"}}
- test place-3.2 {ConfigureSlave procedure, -relheight option} {
- place forget .t.f2
- place .t.f2 -in .t.f -relheight .5
- update
- winfo height .t.f2
- } {40}
- test place-3.3 {ConfigureSlave procedure, -relheight option} {
- place forget .t.f2
- place .t.f2 -in .t.f -relheight .8
- update
- place .t.f2 -relheight {}
- update
- winfo height .t.f2
- } {60}
-
- test place-4.1 {ConfigureSlave procedure, -relwidth option} {
- list [catch {place .t.f2 -relwidth abcd} msg] $msg
- } {1 {expected floating-point number but got "abcd"}}
- test place-4.2 {ConfigureSlave procedure, -relwidth option} {
- place forget .t.f2
- place .t.f2 -in .t.f -relwidth .5
- update
- winfo width .t.f2
- } {75}
- test place-4.3 {ConfigureSlave procedure, -relwidth option} {
- place forget .t.f2
- place .t.f2 -in .t.f -relwidth .8
- update
- place .t.f2 -relwidth {}
- update
- winfo width .t.f2
- } {30}
-
- test place-5.1 {ConfigureSlave procedure, -width option} {
- list [catch {place .t.f2 -width abcd} msg] $msg
- } {1 {bad screen distance "abcd"}}
- test place-5.2 {ConfigureSlave procedure, -width option} {
- place forget .t.f2
- place .t.f2 -in .t.f -width 100
- update
- winfo width .t.f2
- } {100}
- test place-5.3 {ConfigureSlave procedure, -width option} {
- place forget .t.f2
- place .t.f2 -in .t.f -width 120
- update
- place .t.f2 -width {}
- update
- winfo width .t.f2
- } {30}
-
- test place-6.1 {ReconfigurePlacement procedure, computing position} {
- place forget .t.f2
- place .t.f2 -in .t.f -x -2 -relx .5 -y 3 -rely .4
- update
- winfo geometry .t.f2
- } {30x60+123+75}
- test place-6.2 {ReconfigurePlacement procedure, position rounding} {
- place forget .t.f2
- place .t.f2 -in .t.f -x -1.4 -y -2.3
- update
- winfo geometry .t.f2
- } {30x60+49+38}
- test place-6.3 {ReconfigurePlacement procedure, position rounding} {
- place forget .t.f2
- place .t.f2 -in .t.f -x 1.4 -y 2.3
- update
- winfo geometry .t.f2
- } {30x60+51+42}
- test place-6.4 {ReconfigurePlacement procedure, position rounding} {
- place forget .t.f2
- place .t.f2 -in .t.f -x -1.6 -y -2.7
- update
- winfo geometry .t.f2
- } {30x60+48+37}
- test place-6.5 {ReconfigurePlacement procedure, position rounding} {
- place forget .t.f2
- place .t.f2 -in .t.f -x 1.6 -y 2.7
- update
- winfo geometry .t.f2
- } {30x60+52+43}
- test place-6.6 {ReconfigurePlacement procedure, position rounding} {
- frame .t.f3 -width 100 -height 100 -bg #f00000 -bd 0
- place .t.f3 -x 0 -y 0
- raise .t.f2
- place forget .t.f2
- place .t.f2 -in .t.f3 -relx .303 -rely .406 -relwidth .304 -relheight .206
- update
- winfo geometry .t.f2
- } {31x20+30+41}
- catch {destroy .t.f3}
- test place-6.7 {ReconfigurePlacement procedure, computing size} {
- place forget .t.f2
- place .t.f2 -in .t.f -width 120 -height 89
- update
- list [winfo width .t.f2] [winfo height .t.f2]
- } {120 89}
- test place-6.8 {ReconfigurePlacement procedure, computing size} {
- place forget .t.f2
- place .t.f2 -in .t.f -relwidth .4 -relheight .5
- update
- list [winfo width .t.f2] [winfo height .t.f2]
- } {60 40}
- test place-6.9 {ReconfigurePlacement procedure, computing size} {
- place forget .t.f2
- place .t.f2 -in .t.f -width 10 -relwidth .4 -height -4 -relheight .5
- update
- list [winfo width .t.f2] [winfo height .t.f2]
- } {70 36}
- test place-6.10 {ReconfigurePlacement procedure, computing size} {
- place forget .t.f2
- place .t.f2 -in .t.f -width 10 -relwidth .4 -height -4 -relheight .5
- place .t.f2 -width {} -relwidth {} -height {} -relheight {}
- update
- list [winfo width .t.f2] [winfo height .t.f2]
- } {30 60}
-
- catch {destroy .t}
- concat
-